package com.teach.javafxclient.controller.base;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;

/**
 * @author Liang Jianlin
 * @date 2024-05-19 15:40
 */
public class StudentScoreController {
    public Label studentId;
    public Label name;
    public Label score;
    public Button upload;
    public Button edit;
    public TextField scoreFiled;
    public ComboBox gradeComboBox;
    private String courseType;
    public void initialize(){
        ObservableList<String> gradeItem = FXCollections.observableArrayList("A","B","C","D","F");
        gradeComboBox.setItems(gradeItem);
        scoreFiled.setVisible(false);
        scoreFiled.setManaged(false);
        gradeComboBox.setVisible(false);
        gradeComboBox.setManaged(false);
        upload.setManaged(false);
        upload.setVisible(false);
    }
    public void set(String studentNameS,Long studentIdL,String studentScoreS,String type){
        courseType = type;
        name.setText(studentNameS);
        studentId.setText(String.valueOf(studentIdL));
        if(studentScoreS!=null){
            score.setText(studentScoreS);
        }
        edit.setOnAction(e->{
            edit.setVisible(false);
            edit.setManaged(false);
            upload.setManaged(true);
            upload.setVisible(true);
            if(courseType.equals("考核")){
                gradeComboBox.setVisible(true);
                gradeComboBox.setManaged(true);
            }else{
                scoreFiled.setManaged(true);
                scoreFiled.setVisible(true);
            }
        });
    }
}
